using HKB.Common;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
namespace HKB.Data.Dal.S_FriendLinkTableAdapters
{
	[GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), DataObject(true), HelpKeyword("vs.data.TableAdapter"), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DesignerCategory("code"), ToolboxItem(true)]
	public class pr_GetFriendLinkByShopIDTableAdapter : Component
	{
		private SqlDataAdapter _adapter;
		private SqlConnection _connection;
		private SqlCommand[] _commandCollection;
		private bool _clearBeforeFill;
		[System.Diagnostics.DebuggerNonUserCode]
		private SqlDataAdapter Adapter
		{
			get
			{
				if (this._adapter == null)
				{
					this.InitAdapter();
				}
				return this._adapter;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		internal SqlConnection Connection
		{
			get
			{
				if (this._connection == null)
				{
					this.InitConnection();
				}
				return this._connection;
			}
			set
			{
				this._connection = value;
				if (this.Adapter.InsertCommand != null)
				{
					this.Adapter.InsertCommand.Connection = value;
				}
				if (this.Adapter.DeleteCommand != null)
				{
					this.Adapter.DeleteCommand.Connection = value;
				}
				if (this.Adapter.UpdateCommand != null)
				{
					this.Adapter.UpdateCommand.Connection = value;
				}
				for (int i = 0; i < this.CommandCollection.Length; i++)
				{
					if (this.CommandCollection[i] != null)
					{
						this.CommandCollection[i].Connection = value;
					}
				}
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		protected SqlCommand[] CommandCollection
		{
			get
			{
				if (this._commandCollection == null)
				{
					this.InitCommandCollection();
				}
				return this._commandCollection;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public bool ClearBeforeFill
		{
			get
			{
				return this._clearBeforeFill;
			}
			set
			{
				this._clearBeforeFill = value;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public pr_GetFriendLinkByShopIDTableAdapter()
		{
			this.ClearBeforeFill = true;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitAdapter()
		{
			this._adapter = new SqlDataAdapter();
			DataTableMapping dataTableMapping = new DataTableMapping();
			dataTableMapping.SourceTable = "Table";
			dataTableMapping.DataSetTable = "pr_GetFriendLinkByShopID";
			dataTableMapping.ColumnMappings.Add("HLShopURL", "HLShopURL");
			dataTableMapping.ColumnMappings.Add("HLShopName", "HLShopName");
			dataTableMapping.ColumnMappings.Add("ShopURL", "ShopURL");
			dataTableMapping.ColumnMappings.Add("ShopName", "ShopName");
			dataTableMapping.ColumnMappings.Add("UserID", "UserID");
			dataTableMapping.ColumnMappings.Add("shopid", "shopid");
			this._adapter.TableMappings.Add(dataTableMapping);
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitConnection()
		{
			this._connection = new SqlConnection();
			this._connection.ConnectionString = Conn.CurrenConnectionStrings;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitCommandCollection()
		{
			this._commandCollection = new SqlCommand[4];
			this._commandCollection[0] = new SqlCommand();
			this._commandCollection[0].Connection = this.Connection;
			this._commandCollection[0].CommandText = "pr_GetFriendLinkByShopID";
			this._commandCollection[0].CommandType = CommandType.StoredProcedure;
			this._commandCollection[0].Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[0].Parameters.Add(new SqlParameter("@ShopID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[1] = new SqlCommand();
			this._commandCollection[1].Connection = this.Connection;
			this._commandCollection[1].CommandText = "DELETE FROM HLShop_FriendLink\r\nWHERE (ShopID = @ShopID) AND (FriendUserId = @FriendUserID)";
			this._commandCollection[1].CommandType = CommandType.Text;
			this._commandCollection[1].Parameters.Add(new SqlParameter("@ShopID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "ShopID", DataRowVersion.Original, false, null, "", "", ""));
			this._commandCollection[1].Parameters.Add(new SqlParameter("@FriendUserID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "FriendUserId", DataRowVersion.Original, false, null, "", "", ""));
			this._commandCollection[2] = new SqlCommand();
			this._commandCollection[2].Connection = this.Connection;
			this._commandCollection[2].CommandText = "SELECT FriendLinkID, ShopID, FriendUserId FROM HLShop_FriendLink WHERE (ShopID = @ShopID) AND (FriendUserId = @FriendUserId)";
			this._commandCollection[2].CommandType = CommandType.Text;
			this._commandCollection[2].Parameters.Add(new SqlParameter("@ShopID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "ShopID", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[2].Parameters.Add(new SqlParameter("@FriendUserId", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "FriendUserId", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[3] = new SqlCommand();
			this._commandCollection[3].Connection = this.Connection;
			this._commandCollection[3].CommandText = "INSERT INTO HLShop_FriendLink\r\n      (ShopID, FriendUserId)\r\nVALUES (@ShopID,@FriendUserId)";
			this._commandCollection[3].CommandType = CommandType.Text;
			this._commandCollection[3].Parameters.Add(new SqlParameter("@ShopID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "ShopID", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[3].Parameters.Add(new SqlParameter("@FriendUserId", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "FriendUserId", DataRowVersion.Current, false, null, "", "", ""));
		}
		[DataObjectMethod(DataObjectMethodType.Select, true), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual S_FriendLink.pr_GetFriendLinkByShopIDDataTable GetFriendLinkByShopID(int? ShopID)
		{
			this.Adapter.SelectCommand = this.CommandCollection[0];
			if (ShopID.HasValue)
			{
				this.Adapter.SelectCommand.Parameters[1].Value = ShopID.Value;
			}
			else
			{
				this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
			}
			S_FriendLink.pr_GetFriendLinkByShopIDDataTable pr_GetFriendLinkByShopIDDataTable = new S_FriendLink.pr_GetFriendLinkByShopIDDataTable();
			this.Adapter.Fill(pr_GetFriendLinkByShopIDDataTable);
			return pr_GetFriendLinkByShopIDDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual S_FriendLink.pr_GetFriendLinkByShopIDDataTable GetFriendLinkByShopIDFriendUserID(int ShopID, int FriendUserId)
		{
			this.Adapter.SelectCommand = this.CommandCollection[2];
			this.Adapter.SelectCommand.Parameters[0].Value = ShopID;
			this.Adapter.SelectCommand.Parameters[1].Value = FriendUserId;
			S_FriendLink.pr_GetFriendLinkByShopIDDataTable pr_GetFriendLinkByShopIDDataTable = new S_FriendLink.pr_GetFriendLinkByShopIDDataTable();
			this.Adapter.Fill(pr_GetFriendLinkByShopIDDataTable);
			return pr_GetFriendLinkByShopIDDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Delete, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int DeleteFriendLink(int? ShopID, int? FriendUserID)
		{
			SqlCommand sqlCommand = this.CommandCollection[1];
			if (ShopID.HasValue)
			{
				sqlCommand.Parameters[0].Value = ShopID.Value;
			}
			else
			{
				sqlCommand.Parameters[0].Value = System.DBNull.Value;
			}
			if (FriendUserID.HasValue)
			{
				sqlCommand.Parameters[1].Value = FriendUserID.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Insert, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int InsertFriendLink(int? ShopID, int? FriendUserId)
		{
			SqlCommand sqlCommand = this.CommandCollection[3];
			if (ShopID.HasValue)
			{
				sqlCommand.Parameters[0].Value = ShopID.Value;
			}
			else
			{
				sqlCommand.Parameters[0].Value = System.DBNull.Value;
			}
			if (FriendUserId.HasValue)
			{
				sqlCommand.Parameters[1].Value = FriendUserId.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
	}
}
